package Class;

import java.io.*;
public class CourseSelectionSystem {
    public static void main(String[] args) throws IOException{
        Curriculums gdsx=new Curriculums("001","高等数学","教101","周一8：00——9：40");
        Curriculums xxds=new Curriculums("002","线性代数","教102","周二8：00——9：40");
        Curriculums java=new Curriculums("003","Java","教201","周三1：30——3：10");
        Curriculums cyy=new Curriculums("004","C语言","教202","周四1：30——3：10");
        Curriculums dxwl=new Curriculums("005","大学物理","教203","周五8：00——9：40");
        Curriculums tiyu=new Curriculums("006","体育","体育馆","周五10：00——11：40");

        Teachers wang=new Teachers("0001","王老师",'男', new Curriculums[]{gdsx,xxds});
        Teachers zhang=new Teachers("0002","张老师",'男',new Curriculums[]{java,cyy});
        Teachers li=new Teachers("0003","李老师",'女',new Curriculums[]{dxwl});
        Teachers shi=new Teachers("004","石老师",'男',new Curriculums[]{tiyu});

        gdsx.setTeacher(wang);
        xxds.setTeacher(wang);
        java.setTeacher(zhang);
        cyy.setTeacher(zhang);
        dxwl.setTeacher(li);
        tiyu.setTeacher(shi);

        Curriculums sIn1[]=new Curriculums[]{gdsx,xxds,cyy,java,dxwl};
        Curriculums sIn2[]=new Curriculums[]{xxds,java,cyy,dxwl,tiyu,gdsx};
        Students sOut1=new Students();
        Students sOut2=new Students();

        Students liu=new Students("202001","刘同学",'男',sIn1,2020);
        Students zhao=new Students("202002","赵同学",'女',sIn2,2018);

        FileOutputStream in = new FileOutputStream("C:\\Users\\Cuiji\\Desktop\\shiyan6.txt");
        ObjectOutputStream inin = new ObjectOutputStream(in);
        inin.writeObject(liu);
        inin.writeObject(zhao);

        FileInputStream out=new FileInputStream("C:\\Users\\Cuiji\\Desktop\\shiyan6.txt");
        ObjectInputStream otot = new ObjectInputStream(out);
        try {
            sOut1= (Students) otot.readObject();
            sOut2= (Students) otot.readObject();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        sOut1.tuike(cyy);
        sOut2.tuike(java);
        sOut2.tuike(gdsx);

        System.out.println(sOut1.toString());
        for(int i = 0; i<sOut1.Curriculums.length; i++){
            System.out.println(sOut1.Curriculums[i].toString());
        }

        System.out.println("\n"+sOut2.toString());
        for(int i = 0; i<sOut2.Curriculums.length; i++){
            System.out.println(sOut2.Curriculums[i].toString());
        }
    }
}
